NY Uber dataset

All data was taken from fivethirtyeight's data:

https://github.com/fivethirtyeight/uber-tlc-foil-response

In [6]:
In [7]:

Data exploration

In [81]:
Out[81]:
Dispatching_base_num Pickup_date Affiliated_base_num locationID
0 B02617 2015-05-17 09:47:00 B02617 141
1 B02617 2015-05-17 09:47:00 B02617 65
2 B02617 2015-05-17 09:47:00 B02617 100
3 B02617 2015-05-17 09:47:00 B02774 80
4 B02617 2015-05-17 09:47:00 B02617 90
In [4]:
In [5]:
Out[5]:
LocationID Borough Zone
0 1 EWR Newark Airport
1 2 Queens Jamaica Bay
2 3 Bronx Allerton/Pelham Gardens
3 4 Manhattan Alphabet City
4 5 Staten Island Arden Heights
In [6]:
Total zones: 265
Zones represented in Uber dataset: 262
[]

Google Maps API

In [183]:
In [33]:
Out[33]:
[{'address_components': [{'long_name': 'Newark Liberty International Airport',
    'short_name': 'Newark Liberty International Airport',
    'types': ['airport', 'establishment', 'point_of_interest']},
   {'long_name': '3', 'short_name': '3', 'types': ['street_number']},
   {'long_name': 'Brewster Road',
    'short_name': 'Brewster Rd',
    'types': ['route']},
   {'long_name': 'Newark',
    'short_name': 'Newark',
    'types': ['locality', 'political']},
   {'long_name': 'New Jersey',
    'short_name': 'NJ',
    'types': ['administrative_area_level_1', 'political']},
   {'long_name': 'United States',
    'short_name': 'US',
    'types': ['country', 'political']},
   {'long_name': '07114', 'short_name': '07114', 'types': ['postal_code']}],
  'formatted_address': 'Newark Liberty International Airport (EWR), 3 Brewster Rd, Newark, NJ 07114, USA',
  'geometry': {'location': {'lat': 40.6895314, 'lng': -74.1744624},
   'location_type': 'ROOFTOP',
   'viewport': {'northeast': {'lat': 40.6908803802915,
     'lng': -74.17311341970849},
    'southwest': {'lat': 40.6881824197085, 'lng': -74.17581138029149}}},
  'place_id': 'ChIJ7wzsxeFSwokRhvLXxTe087M',
  'plus_code': {'compound_code': 'MRQG+R6 Newark, New Jersey, United States',
   'global_code': '87G7MRQG+R6'},
  'types': ['airport', 'establishment', 'point_of_interest']}]
In [35]:
Out[35]:
[{'bounds': {'northeast': {'lat': 40.8583606, 'lng': -73.918728},
   'southwest': {'lat': 40.6904811, 'lng': -74.1871381}},
  'copyrights': 'Map data ©2019 Google',
  'legs': [{'distance': {'text': '28.7 mi', 'value': 46228},
    'duration': {'text': '46 mins', 'value': 2745},
    'duration_in_traffic': {'text': '57 mins', 'value': 3449},
    'end_address': 'Astoria Park, 19 19th St, Queens, NY 11105, USA',
    'end_location': {'lat': 40.7766471, 'lng': -73.92360819999999},
    'start_address': 'Newark Liberty International Airport (EWR), 3 Brewster Rd, Newark, NJ 07114, USA',
    'start_location': {'lat': 40.6934897, 'lng': -74.1871381},
    'steps': [{'distance': {'text': '10 ft', 'value': 3},
      'duration': {'text': '1 min', 'value': 0},
      'end_location': {'lat': 40.6934748, 'lng': -74.1871072},
      'html_instructions': 'Head <b>southeast</b>',
      'polyline': {'points': 'i}jwFrtxcMBE'},
      'start_location': {'lat': 40.6934897, 'lng': -74.1871381},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.3 mi', 'value': 428},
      'duration': {'text': '1 min', 'value': 28},
      'end_location': {'lat': 40.6914655, 'lng': -74.1832818},
      'html_instructions': 'Keep <b>left</b> at the fork',
      'maneuver': 'fork-left',
      'polyline': {'points': 'e}jwFltxcM@QBMRw@Lk@BKH]Nk@?ELk@Le@?CPw@F[@GBO@U^iBF[H]HW?CBKDMDI@E@CFIDIFI?ADEJKBAFG@AFEDCJGJEHCJABA@?DAB?D?D?F?F?D@H@LB'},
      'start_location': {'lat': 40.6934748, 'lng': -74.1871072},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '400 ft', 'value': 122},
      'duration': {'text': '1 min', 'value': 15},
      'end_location': {'lat': 40.6905439, 'lng': -74.18277929999999},
      'html_instructions': 'Slight <b>left</b> toward <b>Newark International Airport St</b>',
      'maneuver': 'turn-slight-left',
      'polyline': {'points': 'upjwFn|wcMZCRALCHAFCHCFCNGfAa@?I?IAE@G'},
      'start_location': {'lat': 40.6914655, 'lng': -74.1832818},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.3 mi', 'value': 522},
      'duration': {'text': '1 min', 'value': 56},
      'end_location': {'lat': 40.6938378, 'lng': -74.1806707},
      'html_instructions': 'Continue onto <b>Newark International Airport St</b>',
      'polyline': {'points': '{jjwFjywcM?G@E@I?GBMBM?K@M?E?E?KAK?E?EESAMCKAKCGOc@_@u@o@{@q@y@WS[WOIOKSKYKWIIEm@Oc@Is@E_@AW@Q@QBIBIBKDGBIDIDIHEFIHEHGJEJADCDAFCD'},
      'start_location': {'lat': 40.6905439, 'lng': -74.18277929999999},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.3 mi', 'value': 432},
      'duration': {'text': '1 min', 'value': 33},
      'end_location': {'lat': 40.693046, 'lng': -74.18518159999999},
      'html_instructions': 'Keep <b>left</b> to stay on <b>Newark International Airport St</b>',
      'maneuver': 'keep-left',
      'polyline': {'points': 'o_kwFdlwcMC\\?F?F?H?H?F?F@P?B@NBP@F@LBJDJ@HBFDJHNHPHLHJPRFJLLHHDFJRLNJNLTFH@B@FDJBJBF?@@D@F@F@F@H?@@@@H@J@P@D@H?L?J@T?L?LAL?NEd@CJAJG\\IXALc@~A'},
      'start_location': {'lat': 40.6938378, 'lng': -74.1806707},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '1.1 mi', 'value': 1709},
      'duration': {'text': '1 min', 'value': 87},
      'end_location': {'lat': 40.705762, 'lng': -74.1791345},
      'html_instructions': 'Keep <b>left</b> at the fork, follow signs for <b>Turnpike N</b>/<wbr/><b>I-78</b>/<wbr/><b>I-95</b>/<wbr/><b>New York</b>/<wbr/><b>Garden State Pkwy</b>',
      'maneuver': 'fork-left',
      'polyline': {'points': 'qzjwFjhxcM@F@??@?@AB?@IZGLELEHEHGJINGJEHA@MLEFA@A?A@ABGDGFOJEBIDA?IFIBKB?@C?MBG@G?M@M?O?GAMAGAA?MEKCEAAAICIEKGKGm@c@_@YMIOM]WOMOIUOg@_@CCAAWOA?{@k@a@WQMUMSKYOA?WKe@OSGCAA?AAA?ICa@KAAMCKCYGi@I{@MSCQAQB}BSQCk@Em@Iu@Go@GC?m@C}@GOAOAOAM?_@AG?k@?kA@_A@g@C_@C_@GQEWGSISGSIGEKGUMUOSOOOIIIIOQOQOSQUKUMUMW?AKYM]Oc@K_@Kc@kA_Fa@iBU}@Qo@'},
      'start_location': {'lat': 40.693046, 'lng': -74.18518159999999},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '1.4 mi', 'value': 2251},
      'duration': {'text': '2 mins', 'value': 110},
      'end_location': {'lat': 40.7085904, 'lng': -74.15809840000001},
      'html_instructions': 'Keep <b>right</b> at the fork, follow signs for <b>Holland Tunnel</b>/<wbr/><b>New York City</b> and merge onto <b>I-78 Express E</b>/<wbr/><b>Phillipsburg–Newark Expy</b><div style="font-size:0.9em">Toll road</div>',
      'maneuver': 'fork-right',
      'polyline': {'points': '_jmwFpbwcM?EACAC?CAEGOISKSMUOUCCACIMCCMOUUSQWSUOYOYKECGCUGUGWGUC[EGAGASAUAe@?K?A?EAO?A?C?O?A?E?G?A?K?I?A?SAA?Y?a@?kAAoAAO?KAMAIAGAC?ICIEGCIEGEEEEEAACCCECCGIEIEICICGEG?AAECMEQCMAMAOAG?AAQ?K?SAi@?i@AwB?[Ao@?k@?AAo@?q@?u@?[?WA[?W?u@?o@?wC?eB?k@@aDBiFDkD@cA?U?S?EAC?A?ACCH_DBg@@y@?A@UBcAFoAJiCP}C?EDo@Ba@Fm@Hs@LmAJwAZyBFa@BOPaA@GDYDWBKDU@MBK@CDSBGDUBIBK?ADMFQ?ARu@^uAJYLa@Rq@Rk@Pc@LSHOLKRM'},
      'start_location': {'lat': 40.705762, 'lng': -74.1791345},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.1 mi', 'value': 220},
      'duration': {'text': '1 min', 'value': 20},
      'end_location': {'lat': 40.7077749, 'lng': -74.1557198},
      'html_instructions': '<b>I-78 Express E</b>/<wbr/><b>Phillipsburg–Newark Expy</b> turns <b>left</b> and becomes <b>I-78 E</b>/<wbr/><b>Phillipsburg–Newark Expy</b><div style="font-size:0.9em">Toll road</div>',
      'polyline': {'points': 'u{mwFb_scMLc@|AoGZsAFWDQDSFU'},
      'start_location': {'lat': 40.7085904, 'lng': -74.15809840000001},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '1.9 mi', 'value': 3100},
      'duration': {'text': '2 mins', 'value': 141},
      'end_location': {'lat': 40.7229383, 'lng': -74.13314749999999},
      'html_instructions': 'Take the exit toward <b>Interstate 95 N</b><div style="font-size:0.9em">Toll road</div>',
      'maneuver': 'ramp-right',
      'polyline': {'points': 'qvmwFfprcMTo@HQV]B[ZeBPe@L[N_@N[PURYRWTSNOLKXQRQTQTSTS^]DEPQHMFIHODI@CDQ@O@M@QAO?EAKAOCKEQEKEICIGIGIIIGGIGKIQMMIA?OIWIYKSIOEa@MYIGCQG[K[KYKAAOGWMUMSOUKSOWQg@e@IGOMs@m@m@k@_@c@OQSSKMW[KKU]Y_@c@q@S[KQWe@MSIOCGEGo@qAu@eBw@sBc@qAIYUw@q@}BCK_@sA[kAOi@YcASq@Og@GUMe@a@sAOi@Oi@U}@Sm@CG]iAISGQa@gAq@cB?C_AuBa@}@[o@Wi@m@iAO[i@aACCS]S]U]W_@_@k@a@i@a@e@a@e@eBwAq@i@e@YMGEECAOIWMWMUIc@QQGOEGCQEWIEAMCICc@IWE[Cs@KOCICy@Kk@GOCUEIAA?E@EDw@O]ESEsAQA?[Gi@Mi@KOEsA[yAc@i@MCASIA?A?C?C@?@A@'},
      'start_location': {'lat': 40.7077749, 'lng': -74.1557198},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '5.9 mi', 'value': 9503},
      'duration': {'text': '6 mins', 'value': 367},
      'end_location': {'lat': 40.7768571, 'lng': -74.05818339999999},
      'html_instructions': 'Merge onto <b>I-95 N</b><div style="font-size:0.9em">Toll road</div>',
      'maneuver': 'merge',
      'polyline': {'points': 'kupwFdcncMiBi@]Mq@Sy@]_@Qs@]CAYOy@g@GCWQGEWQSOMISMc@[GEaB{Ak@k@[_@CACCCEY[SUUYAAmAaBi@u@c@i@sByCe@q@AAMSGIU]EEkAaBEGcB{B_AmAy@aAo@s@w@u@k@g@e@_@o@e@aAk@WOy@c@CAs@]}@]o@Si@Ow@Qk@MKAICMCA?UEKAKIqAOMA]CEAE?[AOAy@CeACgACK?WAK?W?OAS?gACaBEm@?kBCY?I?gACO?_AG[AG?[EIAWEk@I}@OeAUCA_@Ia@Kc@KA?eB_@GA_Ba@c@Ka@IeAWc@KiAY]KYIGCa@MMCu@WQGOEYKGCo@Uu@Y_A]e@UCAYOa@S[Qs@c@o@a@CAk@a@w@i@i@a@IG_@[e@c@QQEEQQCC[]A?YYe@c@e@g@KK[]SUg@m@EEGG[a@y@iAEGSYWa@KMw@mA]m@Ua@AAMSKQk@gAKU]s@MWSg@]w@_@y@Ui@Qc@Ui@O_@k@uAKUGOSg@a@eA_AaC]{@wAuDKWk@_B[y@k@gBSm@KY?AGOYw@aAwCk@cBY_AOi@Qg@Uw@i@iBQq@Oo@Sy@c@oBAEc@{BKo@AEUsAUgBOmAE_@AMU}BKoAGiAEkACg@G}@Ai@EmAAw@Ay@?C?m@AQ?i@?Y?IAmCA}@?oA?e@?IAeC?GA_B?m@?o@?IAuAA}A?o@?]?QAm@?gBAeCAmC?_@?OC}AA_AA_AKyCMaCAEEg@Em@AIW}BSoAGa@EWIa@AIMm@Ie@Mq@CMI]Oq@Kc@WcAa@uAMc@Mc@Yy@Qc@_@cAmA}CcBmEu@qBSg@{AeEA?[y@y@aCGQSg@Ww@]aAK[KYGQA?IW[{@?AOc@CGWu@?AYy@{AiEiBqFe@iA?AIUK]sAyDUq@?AWu@e@qAq@mB?CSk@O_@m@_B?AGQCGAEGK?ACIm@wAg@iA[q@Q_@Q_@Q_@sAeCqAwB_AwA}@oAm@y@aAoAo@w@KMOQMKqAuA}@}@oBgBy@q@aBoAsBuA_Ak@[S]U_E{Bg@Ya@WaE{B_@SgAm@AAuAw@q@e@}@o@yB{AkAq@i@Ya@U'},
      'start_location': {'lat': 40.7229383, 'lng': -74.13314749999999},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '4.3 mi', 'value': 6965},
      'duration': {'text': '4 mins', 'value': 268},
      'end_location': {'lat': 40.8319211, 'lng': -74.0222169},
      'html_instructions': 'Keep <b>left</b> to stay on <b>I-95 N</b>, follow signs for <b>G Washington Bridge</b>',
      'maneuver': 'keep-left',
      'polyline': {'points': 'kf{wFrn_cMuAKMCe@YsBmAmAs@A?qAs@}Ay@g@WWOWM_@UoCeBm@e@m@e@o@e@e@]OKe@_@y@q@w@q@u@q@q@m@g@g@o@k@i@i@[WuEoEm@k@{AwA_@_@EEg@e@yBsBqCkCg@g@i@g@_B{AqEiEsCmCqBmBeD}CwAsAiL{KaLqKwBqBmAkA][u_@m^]]_CyBa@_@m@g@y@s@iDkCiBqAqCiBkBiAmAs@y@a@}BoA]Sa@S_Ac@UIqAk@q@YwCeAWKkCy@i@Q[IsA_@aDy@qAWmB_@wB_@y@Mm@IgAMOAc@Gu@GgFe@cE]]CiAKw@Iu@G]Cu@Gs@G[Es@Eu@Iu@GqAKsOqAeGg@}AUC?m@KiASw@Qe@OSEQG]MOEKEcA_@g@Ui@Uy@e@e@Wm@_@WQUMWSSOEE[WOKKICCa@[y@o@WSa@[[UCCo@g@g@a@kCsBmCsBOMOKECYW'},
      'start_location': {'lat': 40.7768571, 'lng': -74.05818339999999},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.8 mi', 'value': 1298},
      'duration': {'text': '1 min', 'value': 52},
      'end_location': {'lat': 40.8429035, 'lng': -74.017523},
      'html_instructions': 'Keep <b>right</b> to stay on <b>I-95 N</b>',
      'maneuver': 'keep-right',
      'polyline': {'points': 'o~exFzmxbMoAaAc@[EE_@Ye@]OK]W_Ao@]Wo@e@_B}@s@a@}@_@a@QGCm@Wk@Sm@SyAc@{@WsCu@AAeBe@OEgCs@kBe@A?cBi@w@WWG_@IcAUmAUWEUCKCu@Gs@Gg@CmAE{BE'},
      'start_location': {'lat': 40.8319211, 'lng': -74.0222169},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.3 mi', 'value': 503},
      'duration': {'text': '1 min', 'value': 32},
      'end_location': {'lat': 40.844793, 'lng': -74.0139828},
      'html_instructions': 'Take the <b>U.S. 46 E</b> exit toward <b>Palisades Park</b>',
      'maneuver': 'ramp-right',
      'polyline': {'points': 'cchxFnpwbMWOECEAEAE?MAg@Gi@Km@Qq@QUGu@Se@Kq@]QMIIGGOUEICGCE?ACIEKCEAGCKAMAOAM?KAI@W?G@G@I@K@I@IBMBM@IBIDQHWFUBKTu@\\gAL]'},
      'start_location': {'lat': 40.8429035, 'lng': -74.017523},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.6 mi', 'value': 891},
      'duration': {'text': '1 min', 'value': 54},
      'end_location': {'lat': 40.8434758, 'lng': -74.00361079999999},
      'html_instructions': 'Keep <b>left</b> and merge onto <b>US-46 E</b>/<wbr/><b>Rte 46 E</b>',
      'maneuver': 'keep-left',
      'polyline': {'points': '}nhxFjzvbMLc@Lm@DQ@G?[DUD_@BSFy@B]?G@W@]@]BkBBsDBiB?GBy@@k@B_@?KFy@FcAPqBR{AJm@D[Fa@Ba@RuA\\qCJkAD[De@B[Bc@@i@@uD'},
      'start_location': {'lat': 40.844793, 'lng': -74.0139828},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '2.0 mi', 'value': 3214},
      'duration': {'text': '3 mins', 'value': 188},
      'end_location': {'lat': 40.8584028, 'lng': -73.9777591},
      'html_instructions': 'Keep <b>left</b> to continue on <b>US-46 E</b>',
      'maneuver': 'keep-left',
      'polyline': {'points': 'wfhxFpytbM?_B@c@@I@MFg@Hg@F[H[H[L]\\u@L[BC?AT]t@wAlA_CXi@Tm@@AXiABGF[Lm@RsA@WFk@B_AA_B?KEgAGq@G_AIg@AEE_@G_@Ie@I[IO_@aAQ]Sa@Ye@[c@Y[_CaC[]sAuAuBqB[[uAuAAAuGwG{J{JiAmAA?ACA??ACCk@k@{E}EGEMOGICACCQQc@c@e@c@i@e@gAgAs@s@CCSQSOIGYQMGWKMEICOEUEUEm@G{AQE?e@E[CSCOCUEUGi@MSKs@]e@WYQ{@w@][YWA?w@y@y@y@eBkBUU[YSSOQQQACSUKMU]]k@O[CEMYKUISEK[_A?AAAMe@Kc@GYGYMu@EYGe@C]CYAOAMA]Ci@G{B'},
      'start_location': {'lat': 40.8434758, 'lng': -74.00361079999999},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.2 mi', 'value': 318},
      'duration': {'text': '1 min', 'value': 69},
      'end_location': {'lat': 40.8569938, 'lng': -73.9745301},
      'html_instructions': 'Keep <b>right</b> at the fork, follow signs for <b>US-9W</b>/<wbr/><b>Fort Lee</b>/<wbr/><b>Palisades Pkwy</b>',
      'maneuver': 'fork-right',
      'polyline': {'points': '_dkxF~wobMFc@BUB[D]FU@KJ]BIJ[JUHQp@gAVc@DGXq@N]To@FMNu@La@Pi@'},
      'start_location': {'lat': 40.8584028, 'lng': -73.9777591},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '180 ft', 'value': 55},
      'duration': {'text': '1 min', 'value': 12},
      'end_location': {'lat': 40.8568721, 'lng': -73.9739015},
      'html_instructions': 'Continue straight onto <b>Kelby St</b>',
      'maneuver': 'straight',
      'polyline': {'points': 'e{jxFxcobMHSHiAB_@'},
      'start_location': {'lat': 40.8569938, 'lng': -73.9745301},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '466 ft', 'value': 142},
      'duration': {'text': '1 min', 'value': 25},
      'end_location': {'lat': 40.8562005, 'lng': -73.9724985},
      'html_instructions': 'Take the <b>Interstate 95</b> ramp on the <b>left</b>',
      'maneuver': 'ramp-left',
      'polyline': {'points': 'mzjxFz_obM?K?G@E@C@IDKFQJWHQJSP[LUHMLUFOBEBIBG@G@K?A'},
      'start_location': {'lat': 40.8568721, 'lng': -73.9739015},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '2.2 mi', 'value': 3467},
      'duration': {'text': '5 mins', 'value': 296},
      'end_location': {'lat': 40.8469467, 'lng': -73.9336323},
      'html_instructions': 'Merge onto <b>I-95 Lower Level N</b>/<wbr/><b>U.S. 1 Lower Level N</b><div style="font-size:0.9em">Toll road</div><div style="font-size:0.9em">Entering New York</div>',
      'maneuver': 'merge',
      'polyline': {'points': 'gvjxFbwnbM^u@f@{@Ta@bA}Af@u@h@aAJU@GHQ?AL[DUdAoENi@LaA?CPkA?C@KJw@Hm@T_CBQ@EBUT}DRmDBa@JcA?CDSD[J_ADUFs@@K@I@YH}A?m@?AAo@?A?ACs@?i@HaDP{AFm@Hm@Fm@Hm@Hm@Fm@Hm@Fm@Hm@Fm@Hm@Fm@ZiCFm@@?b@wDP{AFm@Hm@Fm@Hm@P{AFm@l@eFHm@Hm@Fm@P{AHm@Hm@Hq@NwAHm@Fm@Hm@Hm@Fm@Hm@Fm@Hm@Fm@Hm@Fm@Fm@?AHk@@GBY@K@CFi@@EDg@@AFk@?AHk@?AFk@?AFk@?AHk@?AFm@Fm@Hm@Fm@BSD[Lk@BOJe@H]?AFg@@C?EBU@E@C?G@GDYFa@BU?ABMDW?A@E@KD[?EHk@Hm@@GFe@@?Fg@?ED[@I@E?AJk@Da@Ly@Hg@Hg@LaAL_ARsB@M@IZ_D@EDc@BW@CDYH[?AFY@C@A@EFSDMPk@Ne@Nc@@AJ_@b@sA`@sA`@sA`@sAV{@Xy@Nc@Lc@'},
      'start_location': {'lat': 40.8562005, 'lng': -73.9724985},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.1 mi', 'value': 181},
      'duration': {'text': '1 min', 'value': 14},
      'end_location': {'lat': 40.8461775, 'lng': -73.9317441},
      'html_instructions': 'Take exit <b>2</b> on the <b>left</b> for <b>Harlem Riv Dr</b> toward <b>FDR Dr</b>/<wbr/><b>Manhattan</b>',
      'maneuver': 'ramp-left',
      'polyline': {'points': 'm|hxFddgbMBM?C@EBGh@wAPi@DYZ_ALa@?Ab@yA'},
      'start_location': {'lat': 40.8469467, 'lng': -73.9336323},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '2.5 mi', 'value': 4028},
      'duration': {'text': '3 mins', 'value': 197},
      'end_location': {'lat': 40.8111287, 'lng': -73.9348914},
      'html_instructions': 'Keep <b>left</b>, follow signs for <b>FDR Drive</b>/<wbr/><b>Harlem River Drive</b> and merge onto <b>Harlem River Dr</b>',
      'maneuver': 'keep-left',
      'polyline': {'points': 'swhxFjxfbMRm@HWDQBE@CDMBEBCFK@ABELONOPKNGLEJCT?F?B?HBFBFBHFh@`@\\XPL\\XLFDBTLRH@@NDHBNBVDTBL@T?R?ZETAh@G\\Cb@CRAD@N@T@RBRDD@NDVFLDB??@FBLDPFXNvBdA`Ad@`Ad@^RFBXLd@T|@\\RJPFFDNN`Bt@|BfA`Br@fElBz@`@RH|@ZXFRDNDf@HTDb@FD@^BR@R@N@f@B`ABx@?@?b@?b@AH?XA|CK|@ElAEhAEbBGRArAG@?dAGhAInBOh@E~@GBAJATARANA@AL?TCjBM~AIzCQhBGjAEN?V?n@?`@@L?|@?H?N?^?VAV?n@Cj@CzBG\\A^@T?B?X@fADD?J@L?v@B\\AH?H?dAAjACbACB?N?R?F?Z?lD]NGJCRG^ENCZCb@CzA?X?B?@?n@DlEVB@B?D?P@bCP@?L?B@@?@?@?z@D|@FD?B?@?@@B?@?@?F?B?@?P@@?@?J@@?D?f@Bh@@T@hCLT@T@VBT@P@VDTB`@BRDb@H^FD@D@PBH?'},
      'start_location': {'lat': 40.8461775, 'lng': -73.9317441},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.7 mi', 'value': 1077},
      'duration': {'text': '2 mins', 'value': 118},
      'end_location': {'lat': 40.8023823, 'lng': -73.9303369},
      'html_instructions': 'Keep <b>left</b> to stay on <b>Harlem River Dr</b>, follow signs for <b>2 Ave</b>/<wbr/><b>E 125 St</b>',
      'maneuver': 'keep-left',
      'polyline': {'points': 'q|axF`lgbMn@HVBRDR@hAD@?n@@BA@@R?TBXAPAj@GXCB?FAl@ORGRIRIRITIRITKXKTKRMNIRMTOPMXSXSn@c@dFqEr@q@fAcANQNMRSPOPOPOTS`@Wh@]HEJG|BoAb@Q@?XKn@SvAY'},
      'start_location': {'lat': 40.8111287, 'lng': -73.9348914},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.3 mi', 'value': 539},
      'duration': {'text': '1 min', 'value': 49},
      'end_location': {'lat': 40.8009365, 'lng': -73.9293716},
      'html_instructions': 'Take exit <b>17</b> for <b>Robert F. Kennedy Bridge</b> toward <b>Interstate 278</b>/<wbr/><b>Bruckner Expressway</b>/<wbr/><b>Grand Central Parkway</b><div style="font-size:0.9em">Toll road</div>',
      'maneuver': 'ramp-right',
      'polyline': {'points': '{e`xFrofbMV?r@FD?J@TBT@J?B?BAD?DCJEFEJIRMPMFCFAJCFADADAB?@?FAR?D@@?F@D@DBDBBBLPBD@DBH?F@F?F?FAJADAHAHERG^MREFEDA@CBEDGBE@A@E@C@G@G?G?C?EAGAGCEAGEGCEEEECECGCGAEAAAGAKAKAO@M?KBMBOBIBK@EDOJYDOFQ@GDODKDMDOFQ@EFO'},
      'start_location': {'lat': 40.8023823, 'lng': -73.9303369},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.3 mi', 'value': 523},
      'duration': {'text': '1 min', 'value': 31},
      'end_location': {'lat': 40.79862809999999, 'lng': -73.923968},
      'html_instructions': 'Continue onto <b>Robert F. Kennedy Bridge</b><div style="font-size:0.9em">Toll road</div>',
      'polyline': {'points': '{|_xFpifbM@CRg@r@}BdAeDNi@b@qAPi@Ni@`AwC@IBINk@H]HWFOFQJ[Tw@\\_AFKNa@Re@'},
      'start_location': {'lat': 40.8009365, 'lng': -73.9293716},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '2.2 mi', 'value': 3498},
      'duration': {'text': '3 mins', 'value': 178},
      'end_location': {'lat': 40.7721112, 'lng': -73.91975459999999},
      'html_instructions': 'Take the exit onto <b>I-278 W</b>',
      'maneuver': 'ramp-right',
      'polyline': {'points': 'mn_xFxgebMHKJKBGRe@DKFMFMDIN[DKVc@\\q@R]R]R[JQDELQTWFGHIHE@?DEDAHEHCHEJCHAHAJAJ?J?H?J@H@LBJBJBLFJFJFNJb@VNH@@~@h@l@`@VPXNpAv@LH^Tb@VdAr@v@f@f@ZLHXN\\Jn@j@h@b@BBXXLHDBPNbElD\\XrAlAZVXVh@b@h@d@`@\\DDDFl@b@@@TTrD|Cj@d@LJ\\ZZV\\XZV^\\|@t@TRFD\\XPNJFNJNJFDNHHBPHb@P`@L^HD@NBJ@VDV@L@N@P@@?P?^Aj@GXCb@INCHCPEBAVI`@Qb@ULGl@c@d@[rDkChAw@xByAFGBAJGFENMzB}A|B_BzB}AtByATOJG@CXQBCJGt@i@PMROtB{AtAaAJGJIVOpA}@JI^UXQj@a@XSHGHEROROPMPM@ARQPOPO@APORSPQNQPQPUPSLQNULQRWBEHMNWPUNULWnDsFNWJO'},
      'start_location': {'lat': 40.79862809999999, 'lng': -73.923968},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '328 ft', 'value': 100},
      'duration': {'text': '1 min', 'value': 11},
      'end_location': {'lat': 40.771453, 'lng': -73.918954},
      'html_instructions': 'Take the exit toward <b>31 St</b>/<wbr/><b>Astoria Blvd</b>/<wbr/><b>Interstate 278 Alternative</b>',
      'maneuver': 'ramp-right',
      'polyline': {'points': 'uhzwFlmdbMf@g@^k@NSLSLONS'},
      'start_location': {'lat': 40.7721112, 'lng': -73.91975459999999},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '466 ft', 'value': 142},
      'duration': {'text': '1 min', 'value': 51},
      'end_location': {'lat': 40.770441, 'lng': -73.919489},
      'html_instructions': 'Turn <b>right</b> onto <b>29th St</b>',
      'maneuver': 'turn-right',
      'polyline': {'points': 'qdzwFlhdbMf@[HIBADADAB?D?|BvC'},
      'start_location': {'lat': 40.771453, 'lng': -73.918954},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.1 mi', 'value': 168},
      'duration': {'text': '1 min', 'value': 50},
      'end_location': {'lat': 40.7709499, 'lng': -73.9213661},
      'html_instructions': 'Turn <b>right</b> onto <b>Astoria Blvd</b>',
      'maneuver': 'turn-right',
      'polyline': {'points': 'g~ywFxkdbMMr@CNs@|D_@tB'},
      'start_location': {'lat': 40.770441, 'lng': -73.919489},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.1 mi', 'value': 232},
      'duration': {'text': '1 min', 'value': 73},
      'end_location': {'lat': 40.7724743, 'lng': -73.919585},
      'html_instructions': 'Turn <b>right</b> onto <b>27th St</b>',
      'maneuver': 'turn-right',
      'polyline': {'points': 'mazwFpwdbMAFu@_As@{@mAaBe@m@[a@IKEGKMGKOQ'},
      'start_location': {'lat': 40.7709499, 'lng': -73.9213661},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '0.3 mi', 'value': 439},
      'duration': {'text': '1 min', 'value': 87},
      'end_location': {'lat': 40.7753845, 'lng': -73.9230242},
      'html_instructions': 'Turn <b>left</b> onto <b>Hoyt Ave N</b>',
      'maneuver': 'turn-left',
      'polyline': {'points': '}jzwFjldbMYb@o@dAW^QXW`@]h@Wb@aBfCW`@[f@Wb@EFGFGJ]T_Al@c@X}@j@'},
      'start_location': {'lat': 40.7724743, 'lng': -73.919585},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '469 ft', 'value': 143},
      'duration': {'text': '1 min', 'value': 29},
      'end_location': {'lat': 40.7765508, 'lng': -73.9237354},
      'html_instructions': 'Continue straight to stay on <b>Hoyt Ave N</b>',
      'maneuver': 'straight',
      'polyline': {'points': 'c}zwFzaebMiAf@w@`@GD_B~@'},
      'start_location': {'lat': 40.7753845, 'lng': -73.9230242},
      'travel_mode': 'DRIVING'},
     {'distance': {'text': '49 ft', 'value': 15},
      'duration': {'text': '1 min', 'value': 4},
      'end_location': {'lat': 40.7766471, 'lng': -73.92360819999999},
      'html_instructions': '<b>Hoyt Ave N</b> turns <b>right</b> and becomes <b>19th St</b><div style="font-size:0.9em">Destination will be on the left</div>',
      'polyline': {'points': 'md{wFjfebMSY'},
      'start_location': {'lat': 40.7765508, 'lng': -73.9237354},
      'travel_mode': 'DRIVING'}],
    'traffic_speed_entry': [],
    'via_waypoint': []}],
  'overview_polyline': {'points': 'i}jwFrtxcMdCgLfAoFd@y@~@o@p@IjBAZI~Aw@FeABqAKs@u@mBuCaDmAm@sBi@}BCwAj@k@fAGvATdBdAlBxAtBZ|@TzC_@`Dc@~B}@rB_@b@u@h@aAVyAImBeA_JgGmFeBkC]mEYcHi@eHCiBYcAa@_CkBeB{CkE}Pc@oAuAkB{AeA}@[yCa@iAAuAAkGI_Aa@aAuBS}MJqf@FmFZoJfA}NjAsHr@}CtBgHv@sA`@q@xBcJZsAz@{BjAgEhAcBlCyBnB{BHgBk@aByAeAkDiAeDyAeFcEcD}D}ByDaE}JuA{E_DcLmCeJcFyLaEoH{B{C_FaEqCqAqBk@kG{@sCY}H{AcD}@oBc@iDqAkEeCyAcAqDmDqAyAmImL{JmMyDcDwCaBkE_ByBe@{Dk@kGQcS_@qGiA{IqBcHiB_HcCiFuCuFmEeDeDaEcFsD}FaEuIaD{HwIsUiEmM{D_OuBaN_AaOQkXOs_@]{KOeB}AgK_CqJuIkUmIqU{Ku[cFuN_CqFiCeF}FyImCgDmGgGoIcGaH_EsOeJqG}DcBOyCgB_GaDwBkAqLsIw^g]k~AwzAiGuFqOqKmNgHmJeD{HuBqJeBiDa@uUqBk[kCuKiA{D{@{GsCoEyCqEkDcTkPmFkD{CwAyOyEyMsD_Eu@}CWiEK]S_@EqDw@cDeAaAoAY{AF}Af@yBhBsG\\}ETsPRiDv@wGxAuMFcJLcBd@{B|@sBxCwFjAcDl@eDJcFo@sH}@sC{AiCsNwNe`@m`@{GoGgCcAkGq@uA[gCsAmIkIiCoCqB{DgAaEi@iFCiETeB\\oA~AsC|BwG\\eDxA{Cd@sA`GgKVo@hBqIbAwI~@qNh@oEDoGHkEXiCZiCb@wDb@wDfEs^fEu^fAmJdBaMbBmMpCkUjBwG`IiWzA_Fx@kAn@Yl@CzCvBhBr@pAJnBOtC?zA`@zRhJbNjG~Br@~Df@fGFxQq@fQmApLi@xB@dFEdFKzBFnE@zEG|Eq@nBQ`K^rDT~CNtJb@zKjAlC@zDy@fDyAdKiIdFyEzGyDhA_@nBYzALhAOzAs@v@?l@t@EdAa@nAQPq@Lu@YYw@LiBn@uBjIqWrBwG~AeDtBaEnBmC`Aa@vAA~BfApGzD`EhClB`A|CjC`XfUnFrE|B|ApD`AfDAdCg@`CsA|KyHdLaIxF}DfPaLrBaBjCuCpBwC~HoLnAiAREbCvCQbAsArHw@w@cEmF[a@W]iAhB_BdC{EtH_EhCiFnCSY'},
  'summary': 'I-95 N',
  'warnings': [],
  'waypoint_order': []}]
In [41]:
In [42]:
Out[42]:
{'destination_addresses': ['Astoria Park, 19 19th St, Queens, NY 11105, USA',
  'Alphabet City, New York, NY 10009, USA'],
 'origin_addresses': ['Newark Liberty International Airport (EWR), 3 Brewster Rd, Newark, NJ 07114, USA',
  'Statue of Liberty National Monument, New York, NY 10004, USA'],
 'rows': [{'elements': [{'distance': {'text': '48.7 km', 'value': 48745},
     'duration': {'text': '46 mins', 'value': 2746},
     'duration_in_traffic': {'text': '56 mins', 'value': 3347},
     'status': 'OK'},
    {'distance': {'text': '30.6 km', 'value': 30631},
     'duration': {'text': '39 mins', 'value': 2354},
     'duration_in_traffic': {'text': '47 mins', 'value': 2793},
     'status': 'OK'}]},
  {'elements': [{'distance': {'text': '18.1 km', 'value': 18129},
     'duration': {'text': '33 mins', 'value': 1951},
     'duration_in_traffic': {'text': '30 mins', 'value': 1798},
     'status': 'OK'},
    {'distance': {'text': '5.8 km', 'value': 5770},
     'duration': {'text': '16 mins', 'value': 958},
     'duration_in_traffic': {'text': '14 mins', 'value': 842},
     'status': 'OK'}]}],
 'status': 'OK'}

Getting GPS coordinate for all zones

In [90]:
In [92]:
Out[92]:
LocationID Borough Zone lat lng
0 1 EWR Newark Airport 40.689531 -74.174462
1 2 Queens Jamaica Bay 40.605663 -73.871310
2 3 Bronx Allerton/Pelham Gardens 40.865239 -73.846827
3 4 Manhattan Alphabet City 40.725843 -73.977492
4 5 Staten Island Arden Heights 40.556413 -74.173504

Nice little visualization

In [8]:
In [9]:
In [10]:
In [11]:
Out[11]:

Taking it from there

Find a way to smartly query distances: Options:

- 1. reducing the number of nodes by grouping geographically
- 2. reducing the number of nodes by only taking the top 100 or so nodes
- 3. querying for a set of central nodes, the distances from each node to their closest node and trying to correct the errors with L2 distance, or triangulation
- 4. defining passing nodes (bridges) that have to be crossed to change borroughs. We can then query distances from and to these nodes. Each node queries 3 closest passing nodes from itself. 
In [ ]:
In [8]:
In [131]:
Out[131]:
LocationID Borough Zone lat lng Counts
160 161 Manhattan Midtown Center 40.757996 -73.999079 460732
230 231 Manhattan TriBeCa/Civic Center 40.712074 -74.005899 420356
233 234 Manhattan Union Sq 40.735863 -73.991084 419045
78 79 Manhattan East Village 40.726477 -73.981534 407591
248 249 Manhattan West Village 40.734680 -74.004755 323989

Data preparation

In [11]:
Out[11]:
Dispatching_base_num Pickup_date Affiliated_base_num locationID
0 B02617 2015-05-17 09:47:00 B02617 141
1 B02617 2015-05-17 09:47:00 B02617 65
2 B02617 2015-05-17 09:47:00 B02617 100
3 B02617 2015-05-17 09:47:00 B02774 80
4 B02617 2015-05-17 09:47:00 B02617 90
In [12]:
Out[12]:
locationID 1 2 3 4 5 6 7 8 9 10 ... 256 257 258 259 260 261 262 263 264 265
Pickup_date
(1, 1, 0) 0.0 0.0 2.0 58.0 0.0 0.0 54.0 0.0 3.0 0.0 ... 93.0 6.0 4.0 1.0 7.0 17.0 42.0 77.0 0.0 3.0
(1, 1, 1) 0.0 0.0 1.0 39.0 0.0 0.0 40.0 1.0 2.0 0.0 ... 83.0 16.0 7.0 3.0 3.0 13.0 31.0 50.0 0.0 6.0
(1, 1, 2) 0.0 0.0 1.0 50.0 1.0 2.0 49.0 1.0 2.0 0.0 ... 105.0 8.0 12.0 2.0 7.0 10.0 27.0 67.0 0.0 9.0
(1, 1, 3) 0.0 0.0 4.0 49.0 0.0 0.0 58.0 0.0 1.0 2.0 ... 122.0 8.0 10.0 1.0 10.0 16.0 22.0 29.0 0.0 2.0
(1, 1, 4) 0.0 0.0 0.0 30.0 0.0 0.0 34.0 1.0 1.0 0.0 ... 94.0 5.0 5.0 1.0 8.0 7.0 9.0 23.0 0.0 2.0

5 rows × 262 columns

Naive baseline: hourly mean

In [26]:
In [34]:
Out[34]:
Text(0.5, 1.0, 'Mean Uber use per zone in function of the hour')
In [35]:
Out[35]:
1 2 3 4 5 6 7 8 9 10 ... 256 257 258 259 260 261 262 263 264 265
Pickup_date
0 0.000000 0.000000 0.866667 21.200000 0.022222 0.138889 25.883333 0.066667 0.877778 0.961111 ... 50.966667 4.394444 2.116667 0.983333 4.200000 12.777778 11.144444 20.761111 0.000000 1.411111
1 0.005556 0.000000 0.644444 16.716667 0.000000 0.127778 18.900000 0.072222 0.583333 0.711111 ... 38.583333 2.755556 1.594444 0.794444 3.116667 7.594444 6.683333 12.961111 0.000000 0.994444
2 0.000000 0.000000 0.502793 10.972067 0.005587 0.072626 14.301676 0.022346 0.329609 0.525140 ... 27.402235 1.463687 1.290503 0.564246 3.100559 4.955307 4.234637 7.966480 0.011173 0.653631
3 0.000000 0.000000 0.561111 7.433333 0.000000 0.050000 10.683333 0.016667 0.272222 0.477778 ... 18.455556 0.977778 1.144444 0.511111 3.422222 3.411111 3.388889 5.300000 0.000000 0.611111
4 0.016667 0.000000 0.511111 7.944444 0.011111 0.072222 13.094444 0.055556 0.288889 0.961111 ... 14.116667 1.694444 1.133333 0.327778 3.616667 4.011111 4.738889 8.605556 0.000000 0.694444
5 0.022222 0.000000 0.472222 9.700000 0.005556 0.116667 14.233333 0.016667 0.588889 1.088889 ... 14.611111 2.661111 1.394444 0.605556 2.938889 5.122222 7.700000 14.622222 0.000000 1.038889
6 0.072222 0.000000 0.544444 14.572222 0.005556 0.083333 18.516667 0.033333 0.488889 1.400000 ... 19.138889 4.527778 2.888889 0.755556 3.388889 7.300000 15.794444 26.644444 0.000000 1.072222
7 0.033333 0.005556 1.216667 22.705556 0.000000 0.133333 21.072222 0.077778 0.750000 1.838889 ... 20.877778 5.894444 4.116667 1.138889 5.077778 8.383333 42.533333 50.466667 0.000000 2.472222
8 0.033149 0.000000 1.497238 25.209945 0.011050 0.204420 23.160221 0.071823 0.707182 2.707182 ... 24.596685 6.348066 3.281768 1.209945 5.093923 10.563536 62.497238 65.497238 0.000000 1.933702
9 0.016575 0.000000 1.198895 31.817680 0.000000 0.187845 21.806630 0.088398 0.635359 2.740331 ... 28.281768 7.248619 3.044199 0.823204 5.187845 10.342541 55.353591 52.121547 0.005525 1.453039
10 0.011050 0.000000 0.657459 26.392265 0.005525 0.138122 19.718232 0.060773 0.696133 2.099448 ... 27.906077 5.408840 2.817680 0.762431 4.856354 11.464088 35.022099 35.027624 0.000000 1.419890
11 0.049724 0.011050 0.657459 22.022099 0.011050 0.154696 18.690608 0.099448 0.795580 2.138122 ... 25.624309 4.955801 2.281768 0.674033 4.795580 14.215470 28.038674 30.309392 0.000000 1.248619
12 0.044199 0.005525 0.701657 19.767956 0.005525 0.243094 18.281768 0.082873 0.646409 2.248619 ... 25.635359 4.370166 1.878453 0.723757 4.342541 15.552486 24.000000 27.939227 0.005525 1.491713
13 0.038674 0.005525 0.624309 18.165746 0.016575 0.176796 18.779006 0.088398 0.745856 1.513812 ... 26.337017 4.430939 2.292818 0.685083 4.828729 16.596685 22.469613 27.011050 0.000000 1.276243
14 0.038674 0.005525 0.762431 18.486188 0.000000 0.132597 19.618785 0.055249 0.812155 1.779006 ... 26.022099 4.834254 2.314917 0.696133 4.861878 18.287293 22.629834 27.022099 0.000000 1.447514
15 0.077348 0.005525 0.861878 17.226519 0.011050 0.149171 20.082873 0.149171 0.674033 1.817680 ... 27.049724 4.906077 2.392265 0.674033 4.762431 20.779006 27.784530 29.099448 0.000000 1.375691
16 0.033149 0.000000 0.784530 18.176796 0.000000 0.165746 19.408840 0.149171 0.812155 1.646409 ... 27.138122 5.248619 2.066298 0.640884 4.939227 24.596685 30.215470 33.353591 0.000000 1.646409
17 0.055249 0.000000 0.812155 20.154696 0.000000 0.171271 20.889503 0.165746 0.828729 1.900552 ... 29.988950 5.607735 2.320442 1.143646 5.220994 26.524862 36.149171 37.397790 0.005525 1.679558
18 0.016575 0.000000 0.917127 26.176796 0.005525 0.209945 23.309392 0.149171 0.762431 1.779006 ... 37.546961 7.530387 2.425414 0.955801 6.005525 29.856354 37.640884 42.209945 0.005525 1.718232
19 0.005525 0.000000 1.154696 30.950276 0.000000 0.232044 26.607735 0.093923 0.850829 1.823204 ... 44.320442 7.215470 2.502762 1.005525 6.270718 30.243094 36.116022 43.138122 0.000000 1.674033
20 0.011050 0.000000 1.088398 29.740331 0.000000 0.226519 26.348066 0.138122 0.944751 1.469613 ... 49.900552 6.889503 2.370166 0.911602 5.790055 30.685083 26.480663 38.143646 0.005525 1.828729
21 0.000000 0.000000 1.116022 26.972376 0.011050 0.160221 28.674033 0.099448 1.060773 1.337017 ... 54.618785 6.740331 2.591160 1.093923 5.911602 25.596685 22.486188 37.022099 0.000000 1.928177
22 0.000000 0.000000 1.110497 26.519337 0.011050 0.149171 31.237569 0.082873 0.900552 1.453039 ... 62.093923 6.773481 2.751381 1.138122 5.734807 19.762431 20.077348 36.331492 0.000000 1.806630
23 0.000000 0.005556 1.127778 25.266667 0.005556 0.166667 29.744444 0.105556 0.772222 1.272222 ... 61.383333 5.861111 2.672222 1.044444 5.277778 16.955556 16.016667 30.361111 0.000000 1.755556

24 rows × 262 columns

In [78]:
MSE using hourly mean 1308744.890852794

Building the graph

In [113]:
In [114]:
Out[114]:
LocationID Borough Zone lat lng Counts
0 1 EWR Newark Airport 40.689531 -74.174462 105
2 3 Bronx Allerton/Pelham Gardens 40.865239 -73.846827 3684
3 4 Manhattan Alphabet City 40.725843 -73.977492 89319
5 6 Staten Island Arrochar/Fort Wadsworth 40.601212 -74.057918 662
6 7 Queens Astoria 40.764357 -73.923462 90870
In [115]:
Out[115]:
LocationID 1 3 4 6 7 8 9 10 11 12 ... 255 256 257 258 259 260 261 262 263 265
LocationID
1 0.000000 0.371777 0.200290 0.146229 0.261916 0.267020 0.396975 0.388757 0.188799 0.158033 ... 0.223045 0.216177 0.201967 0.317854 0.373694 0.275058 0.162872 0.237794 0.241361 21.881626
3 0.371777 0.000000 0.191062 0.338039 0.126689 0.114856 0.124795 0.200887 0.306118 0.234947 ... 0.183959 0.190799 0.247481 0.175376 0.034256 0.127043 0.226266 0.140810 0.135668 22.238048
4 0.200290 0.191062 0.000000 0.148329 0.066352 0.076322 0.196703 0.198420 0.125293 0.045523 ... 0.026939 0.023318 0.071932 0.126046 0.204909 0.075744 0.038295 0.051838 0.057777 22.081880
6 0.146229 0.338039 0.148329 0.000000 0.211412 0.223402 0.316026 0.281410 0.051780 0.109952 ... 0.154807 0.147655 0.097707 0.220076 0.353218 0.214329 0.119319 0.200147 0.206027 21.978417
7 0.261916 0.126689 0.066352 0.211412 0.000000 0.014897 0.140221 0.164603 0.180550 0.111738 ... 0.057523 0.064176 0.122137 0.099890 0.144610 0.019919 0.103926 0.027971 0.028349 22.142535

5 rows × 252 columns

In [154]:
/home/manu/anaconda3/envs/data/lib/python3.7/site-packages/ipykernel_launcher.py:2: RuntimeWarning: divide by zero encountered in power
  
In [162]:
In [163]:
In [164]:
In [165]:
Out[165]:
{'weight': 0.001471038977134118}

Getting back to the OG problem

Removing unpopular nodes

In [12]:
In [13]:
Out[13]:
Text(0.5, 1.0, 'Counts per zones')
In [145]:
Out[145]:
251
In [146]:
Out[146]:

Plotting by borrough

In [147]:
35 39
42
32 38
36 38
14
1
Number of queries: 4820.0
In [298]:
Out[298]:
In [149]:
Out[149]:
251
In [ ]:

Type Markdown and LaTeX: α2

In [263]:
196/|/| 196/? [00:27<00:00, 7.25it/s]
In [361]:
In [372]:
24/|/| 24/? [00:02<00:00, 10.92it/s]
In [384]:
In [376]:
Out[376]:
20728.0
In [377]:
In [380]:
In [381]:
Out[381]:
251
In [383]:
Out[383]:
True
In [396]:
In [398]:
Out[398]:
16586.0
In [416]:
In [417]:
In [418]:
Out[418]:
21929.0
In [422]:
Out[422]:
LocationID 1 3 4 6 7 8 9 10 11 12 ... 254 255 256 257 258 259 260 261 262 263
LocationID
1 0.0 inf inf inf inf inf inf inf inf inf ... inf inf inf inf inf inf inf inf inf inf
3 inf 0.0 inf inf inf inf inf inf inf inf ... inf inf inf inf inf inf inf inf inf inf
4 inf inf 0.0 inf inf inf inf inf inf inf ... inf inf inf inf inf inf inf inf inf inf
6 inf inf inf 0.0 inf inf inf inf inf inf ... inf inf inf inf inf inf inf inf inf inf
7 inf inf inf inf 0.0 inf inf inf inf inf ... inf inf inf inf inf inf inf inf inf inf
8 inf inf inf inf 1729.0 0.0 inf inf inf inf ... inf inf inf inf inf inf inf inf inf inf
9 inf inf inf inf 18582.0 18790.0 0.0 inf inf inf ... inf inf inf inf inf inf inf inf inf inf
10 inf inf inf inf inf inf inf 0.0 inf inf ... inf inf inf inf inf inf inf inf inf inf
11 inf inf inf 8536.0 inf inf inf inf 0.0 inf ... inf inf inf inf inf inf inf inf inf inf
12 inf inf 5387.0 inf inf inf inf inf inf 0.0 ... inf inf inf inf inf inf inf inf inf inf
13 inf inf 6516.0 inf inf inf inf inf inf 1152.0 ... inf inf inf inf inf inf inf inf inf inf
14 inf inf inf 6995.0 inf inf inf inf 3834.0 inf ... inf inf inf inf inf inf inf inf inf inf
15 inf inf inf inf 15532.0 15740.0 4934.0 inf inf inf ... inf inf inf inf inf inf inf inf inf inf
16 inf inf inf inf 20108.0 20316.0 1757.0 inf inf inf ... inf inf inf inf inf inf inf inf inf inf
17 inf inf inf inf inf inf inf inf inf inf ... inf inf inf inf inf inf inf inf inf inf
18 inf 4422.0 inf inf inf inf inf inf inf inf ... inf inf inf inf inf inf inf inf inf inf
19 inf inf inf inf 22262.0 22470.0 9628.0 13442.0 inf inf ... inf inf inf inf inf inf inf inf inf inf
20 inf 4880.0 inf inf inf inf inf inf inf inf ... inf inf inf inf inf inf inf inf inf inf
21 inf inf inf inf inf inf inf inf 1828.0 inf ... inf inf inf inf inf inf inf inf inf inf
22 inf inf inf inf inf inf inf inf 1828.0 inf ... inf inf inf inf inf inf inf inf inf inf

20 rows × 251 columns

In [419]:
21591
1908
In [475]:
Out[475]:
LocationID Borough Zone lat lng Counts
0 1 EWR Newark Airport 40.689531 -74.174462 105
2 3 Bronx Allerton/Pelham Gardens 40.865239 -73.846827 3684
3 4 Manhattan Alphabet City 40.725843 -73.977492 89319
5 6 Staten Island Arrochar/Fort Wadsworth 40.601212 -74.057918 662
6 7 Queens Astoria 40.764357 -73.923462 90870
7 8 Queens Astoria Park 40.779246 -73.922965 369
8 9 Queens Auburndale 40.757767 -73.783396 3040
9 10 Queens Baisley Park 40.673775 -73.786025 6812
10 11 Brooklyn Bath Beach 40.603885 -74.006208 3559
11 12 Manhattan Battery Park 40.703278 -74.017028 2579
12 13 Manhattan Battery Park City 40.711579 -74.015844 139993
13 14 Brooklyn Bay Ridge 40.626373 -74.029877 35927
14 15 Queens Bay Terrace/Fort Totten 40.792217 -73.776064 3229
15 16 Queens Bayside 40.758557 -73.765437 8880
16 17 Brooklyn Bedford 40.687218 -73.941773 80312
17 18 Bronx Bedford Park 40.870100 -73.885691 6579
18 19 Queens Bellerose 40.736177 -73.713736 3026
19 20 Bronx Belmont 40.853451 -73.889368 9153
20 21 Brooklyn Bensonhurst East 40.613931 -73.992183 8409
21 22 Brooklyn Bensonhurst West 40.613931 -73.992183 10456
22 23 Staten Island Bloomfield/Emerson Hill 40.607453 -74.096311 925
23 24 Manhattan Bloomingdale 40.798896 -73.969780 23717
24 25 Brooklyn Boerum Hill 40.684869 -73.984472 69154
25 26 Brooklyn Borough Park 40.635032 -73.992103 15760
26 27 Queens Breezy Point/Fort Tilden/Riis Beach 40.561638 -73.895342 114
27 28 Queens Briarwood/Jamaica Hills 40.709860 -73.799332 11901
28 29 Brooklyn Brighton Beach 40.578071 -73.959656 4434
30 31 Bronx Bronx Park 40.860863 -73.870632 2299
31 32 Bronx Bronxdale 40.850656 -73.866524 4031
32 33 Brooklyn Brooklyn Heights 40.695929 -73.995552 77788
... ... ... ... ... ... ...
233 234 Manhattan Union Sq 40.735863 -73.991084 419045
234 235 Bronx University Heights/Morris Heights 40.854367 -73.913024 6154
235 236 Manhattan Upper East Side North 40.773565 -73.956555 229344
236 237 Manhattan Upper East Side South 40.773565 -73.956555 284514
237 238 Manhattan Upper West Side North 40.787011 -73.975368 133828
238 239 Manhattan Upper West Side South 40.787011 -73.975368 185741
239 240 Bronx Van Cortlandt Park 40.896424 -73.885284 1416
240 241 Bronx Van Cortlandt Village 40.896424 -73.885284 8430
241 242 Bronx Van Nest/Morris Park 40.841580 -73.870695 7261
242 243 Manhattan Washington Heights North 40.846131 -73.937305 35881
243 244 Manhattan Washington Heights South 40.841708 -73.939355 49303
244 245 Staten Island West Brighton 40.627030 -74.109314 435
245 246 Manhattan West Chelsea/Hudson Yards 40.752725 -74.001643 279100
246 247 Bronx West Concourse 40.831676 -73.922755 13381
247 248 Bronx West Farms/Bronx River 40.843061 -73.881600 3605
248 249 Manhattan West Village 40.734680 -74.004755 323989
249 250 Bronx Westchester Village/Unionport 40.834045 -73.853135 4360
250 251 Staten Island Westerleigh 40.621215 -74.131809 634
251 252 Queens Whitestone 40.792045 -73.809557 5199
252 253 Queens Willets Point 40.760691 -73.840436 815
253 254 Bronx Williamsbridge/Olinville 40.855098 -73.855107 4979
254 255 Brooklyn Williamsburg (North Side) 40.714919 -73.952867 217938
255 256 Brooklyn Williamsburg (South Side) 40.711168 -73.959371 141357
256 257 Brooklyn Windsor Terrace 40.653935 -73.975657 21460
257 258 Queens Woodhaven 40.690137 -73.856609 10059
258 259 Bronx Woodlawn/Wakefield 40.895589 -73.862713 3588
259 260 Queens Woodside 40.753295 -73.906897 20369
260 261 Manhattan World Trade Center 40.711801 -74.013120 67904
261 262 Manhattan Yorkville East 40.770280 -73.950798 108338
262 263 Manhattan Yorkville West 40.776223 -73.949208 133630

251 rows × 6 columns

In [481]:
Out[481]:
In [477]:
Out[477]:
40.6895314
In [ ]: